import java.math.BigInteger;

import com.ibm.icu.math.BigDecimal;

public class hello {
	public static void main(String[] args) {
		testFloat();
	}
	
	public static void testFloat(){
		float fff = 0.5F;
		double ddd = 0.5;
		System.out.println(Float.toHexString(fff));
		System.out.println(Double.toHexString(ddd));
		System.out.println();
		
		float ffflll = Long.MAX_VALUE;
		double dddlll = Long.MAX_VALUE;
		System.out.println(Long.MAX_VALUE);
		System.out.println(ffflll);
		System.out.println(dddlll);
		System.out.println(Float.toHexString(ffflll));
		System.out.println(Double.toHexString(dddlll));
		System.out.println(Long.MAX_VALUE==ffflll);
		System.out.println(Long.MAX_VALUE==dddlll);
		
		System.out.println();
		BigDecimal bdlll = new BigDecimal(Long.MAX_VALUE);
		BigDecimal bdffflll = new BigDecimal(ffflll);
		BigDecimal bddddlll = new BigDecimal(dddlll);
		long lllbdddd = bddddlll.longValue();
		System.out.println(bdlll);
		System.out.println(bdffflll);
		System.out.println(bddddlll);
		System.out.println(lllbdddd);
		System.out.println(Long.MAX_VALUE==lllbdddd);
		System.out.println(bdlll.compareTo(bdffflll));
		System.out.println(bdlll.compareTo(bddddlll));

		System.out.println();
		BigInteger billl = new BigInteger(""+Long.MAX_VALUE);
		System.out.println(billl);
		
		System.out.println();
		long lllfff = (long)ffflll;
		long lllddd = (long)dddlll;
		System.out.println(lllfff);
		System.out.println(lllddd);
	}

	/**
	 * y(n+1) = 1/2 * ( y(n)+x/y(n) )
	 * simulate calculating y = sqrt(x);
	 * @param n
	 * @return
	 */
	public static double sqrt(double x) {
		if (x <= 0) {
			return 0;
		}
		
		int loop_times = 4;
		double y = x / 2;
		while (loop_times > 0) {
			y = 0.5 * (y + x / y);
			loop_times--;
		}
		return y;
	}
}
